<template>
	<view class="main">
			<!-- 资讯 -->
			<view class="fanhui">
				<view class="zuo-left" @click="fanhui">
					<image class="zuo-left" src="@/static/img/向左箭头(1).png" mode=""></image>
					<view class="fanhui-left">返回</view>
				</view>
				<view class="zixun">资讯</view>
			</view>
			<!-- 搜索框 -->
			<view class="sousuokuang">
				<!-- <view class="sousuo-left">搜索关键字</view> -->
				<input type="text" placeholder="搜索关键字" class="sousuo-left">
				<view class="sousuo">
					<image class="sousuo-right" src="@/static/images/index/搜索 (1).png" mode=""></image>
				</view>
			</view>
			<!-- 列表 -->
			<view class="leibiao">
				<!-- 1 -->
				<view class="liebiao-top" v-for="(item,index) in listarr" :key="index">
					<view class="liebiao-left">
						<view class="biaozhun">{{item.title}}</view>
						<view class="shijian">{{item.addtime}}</view>
					</view>
					<view class="liebiao-right">
						<image class="liebiao-img" :src="url+item.picture" mode=""></image>
					</view>
				</view>
			</view>
		</view>
</template>

<script>
	import Index from '@/apis/index.js'
	export default {
		data() {
			return {
				listarr:[],
				url:'http://estate.eshareedu.cn/estate/upload/',
				query:{
					page:1,
					psize:6
				}
			}
		},
		onLoad() {
			this.list()
		},
		methods: {
			fanhui(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
		   async list(){
				uni.showLoading({
					title: '加载中',
			    })
				let res = await Index.usernewslist(this.query)
				// console.log(res);
				uni.hideLoading()
				if(res.errCode==10000){
					let data = []
					if(this.page<=0){
						data = res.data.list
					}else{
						data = [...this.listarr,...res.data.list]
					}
					this.listarr = data
				}
			}
		},
		onPullDownRefresh() {
			// console.log('下拉刷新');
			this.page = 1
			this.list()   
			setInterval(()=>{
				uni.stopPullDownRefresh()
			},1500)
		},
		onReachBottom() {
			// console.log('上拉加载');
			this.query.page++
			this.list()
		}
	}
</script>

<style lang='less'>
@import url('@/static/css/index/RealTime/RealTime.css');
</style>
